from enum import Enum
import os

class ZozzleClassifier(Enum):
    RF:str='RF' # Random Forest
    MNB:str='MNB' # Multinomial Naive Bayes
    BNB:str='BNB' # Bernoulli Naive Bayes
    

zozzle_learner='/home/passwd123/XiaoweiGuo/vscode/code-security/third_party/syntactic-jsdetector/src/learner.py'
zozzle_classifier='/home/passwd123/XiaoweiGuo/vscode/code-security/third_party/syntactic-jsdetector/src/classifier.py'
"python3 src/learner.py --d  BENIGN MALICIOUS --l benign malicious --vd BENIGN-VALIDATE MALICIOUS-VALIDATE --vl benign malicious --clf BNB --mn MODEL-NAME --md MODEL-DIR"

def train(train_good_dir,train_bad_dir,validate_good_dir,validate_bad_dir,model_file,classifier:ZozzleClassifier=ZozzleClassifier.BNB):
    model_dir=os.path.dirname(model_file)
    model_name=os.path.basename(model_file)
    cmd=f'python {zozzle_learner} --d  {train_good_dir} {train_bad_dir} --l benign malicious --vd {validate_good_dir} {validate_bad_dir} --vl benign malicious --clf {classifier.BNB} --mn {model_name} --md {model_dir}'
    
    return os.system(cmd)

def classify(model_file,good_dir,bad_dir):
    cmd=f'python {zozzle_classifier} --d {good_dir} {bad_dir} --m {model_file}'
    return os.system(cmd)

def evaluation(model_file,good_dir,bad_dir):
    cmd=f'python {zozzle_classifier} --d {good_dir} {bad_dir} --l benign malicious --m {model_file}'
    return os.system(cmd)